<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
      思路①：删除所有的回文子串
      思路②：类似于括号匹配，每遍历一个就和末尾的进行匹配，如果匹配成功就弹出
      */
      var removeDuplicates = function (s) {
        let stack = []
        for (let i = 0; i < s.length; i++) {
          if (!stack.length) {
            stack.push(s[i])
            continue
          }
          let n = stack[stack.length - 1]
          if (n == s[i]) {
            stack.pop()
          } else {
            stack.push(s[i])
          }
        }
        console.log(stack)
      }
      removeDuplicates('abbacd')
    </script>
  </body>
</html>
